﻿using OddUserManager.Model;
using System;
using System.Collections.Generic;
using System.Text;

namespace OddUserManager.Data.IRepositories
{
    public interface IRepository
    {

    }


    public interface IRepository<TEntity, TPrimaryKey> : IRepository where TEntity : Entity<TPrimaryKey>
    {
        /// <summary>
        /// 获取实体集合
        /// </summary>
        /// <returns></returns>
        IEnumerable<TEntity> GetAllList();


        TEntity Get(TPrimaryKey id);


        bool Insert(TEntity entity);


        bool Update(TEntity entity);


        bool InsertOrUpdate(TEntity entity);


        void Delete(TEntity entity);
        void Delete(int id);

        void DeleteBatch(List<int> ids);

        void Delete(TPrimaryKey id, string tableName, string IdColumnName);

        /// <summary>
        /// 分页获取数据
        /// </summary>
        /// <param name="startPage">起始页</param>
        /// <param name="pageSize">页面条目</param>
        /// <param name="rowCount">数据总数</param>
        /// <param name="where">查询条件</param>
        /// <param name="order">排序</param>
        /// <returns></returns>
        IEnumerable<TEntity> LoadPageList(int startPage, int pageSize, out int rowCount, Func<TEntity, bool> where, Func<TEntity, object> order);

    }

    public interface IRepository<TEntity> : IRepository<TEntity, int> where TEntity : Entity
    {

    }
}
